/**
 * \file   firfilter.h
 *         Implements a FIR filter with 30 taps
 * \author Manuel Leiva , Esteban Zu?iga, Jorge Hidalgo
 * \date   2012.03

 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 *
 * $Id: firfilter.h $
 */

#ifndef FIRFILTER_H
#define FIRFILTER_H

#include "common_defs.h"


class firfilter
{
public:

    /* main Fir filter structure */
    struct tFirMainStructure {
        int hist_pos;
        int fir_order;
        float fir_fc[2];
        eFirWindType firWinType;
        eFirType firType;
        double fir_atenuation;
        float history[MAX_FIR_ORDER];
        float coefs[MAX_FIR_ORDER];
        float window[MAX_FIR_ORDER];
    } tFirMainStruct_;

    firfilter();
    ~firfilter();

    /* Init the filter operation */
    void init(tFirMainStructure* tFirMainStruct_);

    /* Filter the in buffer and leave the result in out */
    void filter(
        int blockSize,
        float* in,
        float* out,
        tFirMainStructure* tFirMainStruct_);

    /* Reset the filter */
    void reset(tFirMainStructure* tFirMainStruct_);

    void GetWindow(
        float *pWindow,
        eFirWindType type,
        int length);

    void FirCoeff(
        float *pBetaCoeff,
        int order,
        float *pBandEdge,
        eFirType type,
        float *pWind);
};

#endif // FIRFILTER_H
